//
//  NSObject+EV.h
//  EVClub
//
//  Created by sam on 14-8-22.
//  Copyright (c) 2014年 BitRice. All rights reserved.
//

#import <mach/mach_time.h>
#import <Foundation/Foundation.h>

extern id ev_castObj(id obj, Class aClass);

@interface NSObject (EV)
@property NSObject *ev_exObject;

// 代码执行时间测试
-(void) ev_executeTime:(dispatch_block_t)block;

// GCD 线程封装

-(void) ev_asyncTask:(dispatch_block_t)block;

-(void) ev_syncTaskOnMain:(dispatch_block_t)block;

-(void) ev_asyncTask:(dispatch_block_t)block after:(NSTimeInterval)delay;

-(void) ev_syncTaskOnMain:(dispatch_block_t)block after:(NSTimeInterval)delay;

-(void) ev_asyncTask:(dispatch_block_t)block returnOnMain:(dispatch_block_t)block2;

-(void) ev_asyncTask:(dispatch_block_t)block afterExecBlock2:(dispatch_block_t)block2;


-(void) ev_execOnceOnKey:(NSString*)key block:(dispatch_block_t)block;

// 对一个view立刻应用本地化,注释内容请参考考UIViewController+X对其进一步封装的函数
- (void)ev_localizeOnView:(UIView*)view
       fromStringTable:(NSString*)table
           adjustLabel:(BOOL)adjustLabel
             skipViews:(NSArray*)skipViews;

// 从自身类名的表中根据一个Key取出本地化后的字串
- (NSString*)ev_locStringByKey:(NSString*)key;

// Advance Skill：类别里实现自身方法的Hook
+ (BOOL)ev_implInstanceMethodHookForClass:(__unsafe_unretained Class)targetClass
                        originalMethod:(SEL)originalMethod
                             newMethod:(SEL)newMethod;
+ (BOOL)ev_implClassMethodHookForClass:(__unsafe_unretained Class)targetClass
                     originalMethod:(SEL)originalMethod
                          newMethod:(SEL)newMethod;

+ (BOOL)ev_haveInstanceMethod:(SEL)selector;
- (BOOL)ev_haveInstanceMethod:(SEL)selector;
@end
